// pages/orderInfo/orderInfo.js
const { getTargetTime }=require('../../utils/util');
import Dialog from '@vant/weapp/dialog/dialog';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    vip:true,
    orderNum:null,
    orderInfo:{
      address:{
        area_code: "",
        area_text: "河南省郑州市中原区",
        card_back_url: null,
        card_front_url: null,
        card_id: "",
        detail: "升龙又一城",
        email: "16712836619@qq.com",
        idcard: "",
        mobile: "16712836619",
        name: "郑女士",
      },
      amount: "46.00",
      cost_detail: {freight_cost: 0, discount_coust: 0, goods_cost: "4600", coupons: [], coupons_money: 0},
      created_at: "2021-03-12 09:50:44",
      num: 1,
      order_goods: [
        {
          cover: "https://yceat-20200506.oss-cn-shanghai.aliyuncs.com/goods/cover/9bddd43bcb40b1464104f4f91b808b22.png",
          goods_sn: "20200902155347681720",
          group_time_limit: 0,
          id: "3596",
          is_cheap: 0,
          needidcard: 0,
          num: 1,
          pintuan: 0,
          price: 79,
          sell_price: 46,
          sku_id: 2965,
          start_group_nums: 0,
          supplier: "自营",
          tags: "初桃粉",
          title: "蕉下   冰薄系列防晒围巾【初桃粉】",
          vip_price: 46
        }, {
          cover: "https://yceat-20200506.oss-cn-shanghai.aliyuncs.com/goods/cover/9bddd43bcb40b1464104f4f91b808b22.png",
          goods_sn: "20200902155347681720",
          group_time_limit: 0,
          id: "3596",
          is_cheap: 0,
          needidcard: 0,
          num: 1,
          pintuan: 0,
          price: 79,
          sell_price: 46,
          sku_id: 2965,
          start_group_nums: 0,
          supplier: "自营",
          tags: "初桃粉",
          title: "蕉下   冰薄系列防晒围巾【初桃粉】",
          vip_price: 46
        }
      ],
      order_no: "202103100917440001",
      related_no: "2103100917440001",
      state: 0,
      state_text: "等待付款",
      type: 1,
      uid: 3877,
      updated_at: "2021-03-12 09:40:44",
    },
    time: 30*60*100,
  },

  cancelOrder(){
    const temp=`orderInfo.state`;
    Dialog.confirm({
      message: '确认要取消订单吗?',
    })
      .then(() => {
        // on confirm
        //发送请求并同步数据
        this.setData({
          [temp]:-1
        })
      })
      .catch(() => {
        // on cancel
      });
  },
  onGoToPay(){
    //页面跳转,将订单编号
    wx.navigateTo({
      url: '/pages/payment/payment',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //有接口时直接获取订单编号,根据订单编号获取订单信息
    //以下为测试
    if(options.detail){
      const orderInfo=JSON.parse(options.detail);
      this.setData({
        orderInfo
      },()=>{
        
      })
    }
   
  },

  //获取过去某一个时空的时间戳
  


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})